#! /usr/bin/env python
# -*- coding: utf-8 -*-

from playwright.sync_api import Page

from common.base_page import BasePage
from common.logger import logger
from locators.majorHazardSourceSafety.olMonitorWarn.historyWarn.loc_query import LocQuery


class QueryList(BasePage):

    def __init__(self, page: Page):
        super().__init__(page)
        self.switch_menu('重大危险源安全管理')
        self.switch_menu('在线监测预警')
        self.switch_menu('历史预警')

    def query_total_list(self, warn_name, warn_level, company_name, warn_start_time, warn_end_time, deal_start_time,
                         deal_end_time):
        logger.info('开始历史预警查询测试')
        logger.info('输入预警名称')
        self.fill(LocQuery.loc_warn_name, warn_name)
        logger.info('选择预警等级')
        self.select(LocQuery.loc_warn_level, warn_level)
        logger.info('选择企业名称')
        self.select(LocQuery.loc_company_name, company_name)
        logger.info('输入预警时间')
        self.fill_date_time(LocQuery.loc_warn_time, warn_start_time, warn_end_time)
        logger.info('输入处置完成时间')
        self.fill_date_time(LocQuery.loc_deal_time, deal_start_time, deal_end_time)
        self.click(LocQuery.loc_query, exact=True)

    def reset(self):
        """
        测试重置
        :return:
        """
        self.click(LocQuery.loc_reset, exact=True)
